import request from '@/utils/request'

export default {
  //1 讲师列表（条件查询分页）
  //current当前页 limit每页记录数 teacherQuery条件对象
  getTeacherListPage(current, limit, teacherQuery) {
    return request({
      //url: '/eduservice/teacher/pageTeacherCondition/'+current+"/"+limit,
      url: `/eduservice/edu-teacher/pageTeacherCondition/${current}/${limit}`,
      method: 'post',
      //teacherQuery条件对象，后端使用RequestBody获取数据
      //data表示把对象转换json进行传递到接口里面
      data: teacherQuery
    })
  },
  //删除讲师
  deleteTeacherId(id) {
    return request({
      url: `/eduservice/edu-teacher/${id}`,
      method: 'delete'
    })
  },
  //添加讲师
  //添加讲师的方法，添加教师，前端点击按钮，vue调用后端的接口，由后端的方法来执行将---前端提交的数据-----后端处理保存在数据库中
  //js和后端联系，url路径在后端是/eduservice/edu-teacher/addTeacher      url: `/eduservice/edu-teacher/addTeacher`,
  //后端的接受请求是post请求，postmapping      method: 'post',
  //接受的数据是json数据，@RequestBody      data: teacher
  //api定义接口地址。
  addTeacher(teacher) {
    return request({
      url: `/eduservice/edu-teacher/addTeacher`,
      method: 'post',
      data: teacher
    })
  },
  //根据id查询讲师
  getTeacherInfo(id) {
    return request({
      url: `/eduservice/edu-teacher/getTeacher/${id}`,
      method: 'get'
    })
  },
  //修改讲师
  updateTeacherInfo(teacher) {
    return request({
      url: `/eduservice/edu-teacher/updateTeacher`,
      method: 'post',
      data: teacher
    })
  }
}
